Skip to content

Conversation

@AvenJose
Copy link

Adds a small heuristic warning to pull_request_read:get_review_comments when the marshaled payload is large enough that some MCP clients may truncate it.

Motivation: large review comments (big diff_hunk/bodies) can cause the tool response to be cut off, hiding later comments and confusing agents. The warning suggests retrying with a smaller perPage.

Changes:

  • pkg/github/pullrequests.go: if payload > ~8KB, return a leading WARNING text block plus the JSON.
  • pkg/github/pullrequests_test.go: new unit test covering the warning path.

Behavior is unchanged for normal-sized payloads.

@AvenJose AvenJose requested a review from a team as a code owner December 12, 2025 02:33
Copilot AI review requested due to automatic review settings December 12, 2025 02:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a heuristic warning to the get_review_comments method when the marshaled payload exceeds approximately 8KB. This helps AI agents identify when MCP clients may truncate responses, suggesting they retry with a smaller perPage parameter to avoid missing comments.

Key changes:

  • Introduced a threshold constant (8KB) to detect potentially truncated payloads
  • Modified the response format to include a warning message when the threshold is exceeded
  • Added comprehensive test coverage for the large payload warning scenario

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
pkg/github/pullrequests.go Added mcpLargePayloadWarningThresholdBytes constant and logic to return a multi-content result (warning + data) when payload size exceeds threshold
pkg/github/pullrequests_test.go Added unit test that creates a large payload scenario and verifies both warning and data content are returned correctly

Copy link
Collaborator

@SamMorrowDrums SamMorrowDrums left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing review comments on fork PRs - this is a brief test for #1749 which fixed a bug where leaving review comments on fork PRs wasn't working.


On the PR itself: This is a nice defensive improvement! Adding warnings for large payloads that may get truncated by MCP clients is helpful for agent debugging. The 8KB threshold seems reasonable, and the test coverage looks good.

Copy link
Collaborator

@SamMorrowDrums SamMorrowDrums left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing pending review submission on fork PR - verifying fix from #1749

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants